//
//  KZBaseReloadView.m
//  kangzhipifuyisheng
//
//  Created by 唐开江 on 15/5/27.
//  Copyright (c) 2015年 KangZhi. All rights reserved.
//

#import "KZBaseReloadView.h"
#import "NSString+Help.h"
@implementation KZBaseReloadView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        UIButton *reloadBtn = [[UIButton alloc] initWithFrame:CGRectMake((frame.size.width - 80) / 2, 150, 80, 80)];
        [reloadBtn setTitle:@"重新加载" forState:UIControlStateNormal];
        [reloadBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [reloadBtn setTitleColor:[UIColor redColor] forState:UIControlStateHighlighted];
        reloadBtn.backgroundColor = [UIColor hexFloatColor:@"f8f8f8"];
;
        self.backgroundColor = [UIColor hexFloatColor:@"f8f8f8"];
        [reloadBtn addTarget:self action:@selector(baseReloadData) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:reloadBtn];
        
        UILabel* lbl = [[UILabel alloc] init];
        lbl.text = @"请检查网络，重新加载";
        lbl.textColor = [UIColor lightGrayColor];
        lbl.font = [UIFont systemFontOfSize:15];
        CGSize s = [lbl.text sizeWithFont:[UIFont systemFontOfSize:15] andMaxSize:CGSizeMake(MAXFLOAT, screenWidth)];
        lbl.frame = CGRectMake((frame.size.width - s.width ) /2, 240, s.width, s.height);
        [self addSubview:lbl];
    }
    return self;
}

//重新加载数据
- (void)baseReloadData
{
// NSLog(@"%s",__func__);
    if (self.reloadBlock) {
        self.reloadBlock();
        
        //加载完就移除自己
        [self removeFromSuperview];
    }
}
@end
